-
Notifications
You must be signed in to change notification settings - Fork 8k
Allow arbitrary const expressions in backed enums #8190
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Assigning a static property a constant expr of the wrong type gets you a TypeError (thus should be identical here). Everything else probably should just throw an Error. In case |
8d3812a to
f77bef3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nikic The backing table is now built when first accessing a constant or when first calling from/tryFrom. Let me know if you think this is acceptable.
Closes phpGH-7821 Closes phpGH-8190 Closes phpGH-8418
Closes GH-7821
Open issues:
ZSTR_HAS_CE_CACHE(class_name)returnstruefor"self"even thoughzend_alloc_ce_cachespecifically guards for that. Sounds like memory corruption but I couldn't figure out where yetWe probably need more forgiving error handling thanAll other errors inzend_error_noreturnnow that the errors are moved to runtime.zend_do_link_classseem to be fatal so I think this is consistent.enum_backing_tableto store the case directly but that might not actually work for internal enums (or we changezend_enum_add_casenot to modify the backing table anymore and move that to after the constants have been initialized)Can we add theThat would require tracking dependencies of all classes in all expressions so likely not feasible.backed_enum_tableto the inheritance cache to avoid re-population on every request?